using System;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ScottCateAjax2008
{
    public partial class Navigation : Page
    {
        protected void Page_Load ( object sender, EventArgs e )
        {
            Tree1.DataSource = new SiteMapDataSource();
            Tree1.DataBind();

            foreach ( TreeNode child in Tree1.Nodes )
            {
                CollapseChildNodes( child );
            }
        }

        private static void CollapseChildNodes( TreeNode node )
        {
            if(node.Depth > 0)
                node.Collapse();
            foreach (TreeNode child in node.ChildNodes)
            {
                CollapseChildNodes(child);
            }
        }
    }
}